package file;

import java.io.File;
import java.io.FileFilter;

/**
 * 获取当前目录所有名字中含有”a“的子项
 */
public class Test2 {
    public static void main(String[] args) {
        File dir=new File(".");
        if (dir.isDirectory()){
            FileFilter filter=new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name =file.getName();
                   // return name.indexOf("a")>=0;
                    return name.contains("a");
                                    }
            };
            File []subs=dir.listFiles(filter);
            for (int i = 0; i <subs.length ; i++) {
                System.out.println(subs[i].getName());
            }
        }
    }


}
